package plugins.dice;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

public class DiceView extends JDialog
{
	/**
	 * Default Serial-Version-ID
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * The tabpanel which stores all panels
	 */
	private JTabbedPane tabpanel;
		
	/**
	 * Creates the Tabpanel
	 * 
	 */
	public DiceView(JFrame parent)
	{
		super(parent, true);
		this.tabpanel = new JTabbedPane();
		add(this.tabpanel);		
			
		setSize(500, 500);		
		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
	}
	
	/**
	 * Displays or closes the frame.
	 * @param show if true, the frame is shown, if false the frame is closed and disposed
	 */
	public void display(boolean show)
	{
		if(show) {
			setVisible(true);
		}
		else {
			setVisible(false);
			dispose();
		}
	}
	
	/**
	 * This will add a new Plugin to the listbox
	 * @param pluginname The name of the plugin (will appear in the LIstbox)
	 * @param panel The panel which will be shown
	 */
	public void addPlugin(String pluginname, JPanel panel)
	{
		this.tabpanel.addTab(pluginname, panel);
	}
}
